package com.sunspring.jbug.service;

import com.sunspring.jbug.bean.UserInfo;
import com.sunspring.jbug.common.exception.JbugException;
import com.sunspring.jbug.mapper.UserMapper;
import com.sunspring.jbug.support.EmailSupport;
import com.sunspring.jbug.support.LocalCache;
import com.sunspring.jbug.util.CommonUtil;
import com.sunspring.jbug.util.Md5Util;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author wulei
 * @date 2019-02-27
 **/
@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;


    /**
     * 新增单个用户
     * @param userInfo UserInfo
     */
    public void add(UserInfo userInfo) {
        userInfo.setPassword(Md5Util.DEFAULT_PWD);
        userMapper.add(userInfo);
    }

    /**
     * 根据Id获取用户信息
     * @param userId 用户Id
     * @return UserInfo
     */
    public UserInfo getById(int userId) {
        return userMapper.selectById(userId);
    }

    /**
     * 条件参数查询
     * @param userInfo UserInfo
     */
    public List<UserInfo> getSelective(UserInfo userInfo) {
        return userMapper.selectSelective(userInfo);
    }





}
